﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using fanfu.Common;

namespace fanfu.Business
{
    public class BrowseLimitRule
    {
        #region 获取所有浏览限制信息
        /// <summary>
        /// 获取所有浏览限制信息
        /// </summary>
        public DataTable GetAllBrowseLimitInfo()
        {
            string sqlString = "SELECT * FROM BrowseLimit ORDER BY CreateTime DESC";
            DataTable dt = SqlHelper.GetDataTable(sqlString);
            return dt;
        }
        #endregion

        #region 添加一条浏览限制信息
        /// <summary>
        /// 添加一条浏览限制信息
        /// </summary>
        /// <param name="value">需要限制的区域或IP</param>
        /// <returns></returns>
        public int InsertBrowseLimit(string value)
        {
            string sqlString = string.Format("INSERT INTO BrowseLimit (AreaorIP,CreateTime) VALUES('{0}','{1}')", value, DateTime.Now.ToString());
            return SqlHelper.ExecuteCommand(sqlString);
        }
        #endregion

        #region 删除指定ID的浏览限制信息
        /// <summary>
        /// 删除指定ID的浏览限制信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public int DeleteBrowseLimit(string ID)
        {
            string sqlString = "DELETE FROM BrowseLimit WHERE ID=" + ID;
            return SqlHelper.ExecuteCommand(sqlString);
        }
        #endregion
    }
}
